//============================================================================
// Name        : Player.cpp
// Author      : Piotr Brygidyn
// Version     : 1.0
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include "Player.h"
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

Player::Player(string name) : name(name), firstDice(0), secondDice(0), sum(0), winner(false) {
}

Player::~Player() {
        cout << "Deleting player: " << this->name << endl;
}

int Player::draw(void) {
        firstDice = rand() % 6 + 1;
        secondDice = rand() % 6 + 1;
        sum = firstDice + secondDice;
        cout << "Player: " << this->name << ", Score: " << sum << endl;
        return sum;
}

string Player::getName() const {
        return name;
}

int Player::getSum() const {
        return sum;
}

bool Player::getWinner() const{
        return winner;
}

bool & Player::setWinner() {
        return winner;
}

ostream & operator<<(ostream & out, const Player & p) {
        out << "Player name: " << p.getName() << " got result: " << p.getSum() << endl;
        return out;
}


